package my.graduation.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import my.graduation.dto.PatRegScheDto;
import my.graduation.entity.RegistrationSpots;
import my.graduation.enums.HttpCodeEnums;
import my.graduation.mapper.RegistrationSpotsMapper;
import my.graduation.result.Result;
import my.graduation.service.RegistrationSpotsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: RavenLyn
 * @Date: 2024-12-18
 */
@Service
public class RegistrationSpotsServiceImpl extends ServiceImpl<RegistrationSpotsMapper, RegistrationSpots> implements RegistrationSpotsService {

    @Autowired
    private RegistrationSpotsMapper registrationSpotsMapper;
    /**
     * 根据regScheId获取医生挂号号源
     * @param dto
     * @return
     */
    @Override
    public Result<List<RegistrationSpots>> patientGetRegSpotsList(PatRegScheDto dto) {
        if(dto.getRegScheId() != null){
            List<RegistrationSpots> list = list(Wrappers.<RegistrationSpots>lambdaQuery()
                    .eq(RegistrationSpots::getRegScheId, dto.getRegScheId())
                    .orderByAsc(RegistrationSpots::getId));
            return Result.success(list);
        }else {
            return Result.error(HttpCodeEnums.SYSTEM_ERROR);
        }
    }

    /**
     * 患者-占号
     * @param regSpotsId
     * @return
     */
    @Override
    public Boolean gainOne(Integer regSpotsId) {
        return registrationSpotsMapper.gainOne(regSpotsId);
    }

    /**
     * 患者-还号
     * @param regSpotsId
     * @return
     */
    @Override
    public Boolean returnOne(Integer regSpotsId) {
        return registrationSpotsMapper.returnOne(regSpotsId);
    }
}
